package com.example.springsecurity.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger配置类
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {


    @Bean
    public Docket createApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                //apiInfo 用来增加API相关信息
                .apiInfo(apiInfo())
                .select()
                //选择搜索根路径
                .apis(RequestHandlerSelectors.basePackage("com.example.springsecurity.controller"))
                //匹配所有路径
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("系统")
                .contact(new Contact("lxz","","2069762101@qq.com"))
                .version("1.0")
                .build();
    }
}
